package cn.tedu.basic.Test1;

import java.util.*;

//测试hashmap
public class HashMap {
    public static void main(String[] args) {
       Map<Integer ,String> ma =new java.util.HashMap<>();
       ma.put(77,"thb");
       ma.put(88,"bjb");
       ma.put(99,"hbkj");
       System.out.println(ma);
       Set<Integer> s =ma.keySet();//获取每个key
       for (Integer in : s){
           String st =ma.get(in);
           System.out.println(in +st);
       }
       Iterator<Integer> it =s.iterator();//运通迭代器
       while (it.hasNext()){
          Integer In =it.next();
          String st=ma.get(In);
           System.out.println(In + st);
       }

       Collection<String> col =ma.values();//获取每个values
       for (String str : col){
           System.out.println(str);
       }
       Iterator it1 =col.iterator();// 迭代器
       while (it1.hasNext()){
           Object ob =it1.next();
           System.out.println(ob);
       }
       Set<Map.Entry<Integer,String>> m =ma.entrySet();//获取每个map
       for (Map.Entry<Integer,String> n : m){
         Integer in =  n.getKey();
         String st = n.getValue();
           System.out.println(in + st);
       }
       Iterator<Map.Entry<Integer,String>> it2 =m.iterator();//迭代器
       while (it2.hasNext()){
           Map.Entry<Integer,String> map =it2.next();
           Integer in3 =map.getKey();
           String st3 =map.getValue();
           System.out.println(in3 + st3);
       }

    }
}
